#ifndef TRANSPORT_H
#define TRANSPORT_H

#include <QObject>
#include "free-cube/freecube.h"
#include "free-cube/notation.h"


class Clock;
//namespace fc {struct Time;}

class Transport : public QObject
{
    Q_OBJECT
public:
    explicit Transport (int samplerate = 48000, QObject *parent = 0);
    ~Transport();
    void set_samplerate(int samplerate) { samplerate_ = samplerate; }
    void set_tempo(float bpm = 120.); // considering it is constant, no tempotrack
    float tempo(){return tempo_;}
    void set_signature(const fc::TimeSignature & time_signature_);
    void set_signature(const QString & time_signature_);
    void set_clock(Clock & clock){clock_ = &clock;}
    QString position();
    fc::TimeT position_in_ticks();

    void set_size_to_process(size_t total_size){
        size_counter_ = total_size;}
    fc::TimeT process_frames();
    fc::TimeT ticks_of_current_stretch();

signals:    
public slots:
    void start(){is_started_ = true;}
    void stop(){is_started_ = false;}
    void set_locators(fc::TimeT l, fc::TimeT r, bool is_looping);
private:
    struct Locators;
    int samplerate_;
    float tempo_; // bpm
    fc::TimeSignature time_signature_;
    Clock * clock_;
    size_t size_counter_;
    size_t frames_of_stretch_;
    Locators * locators_;
    bool is_started_;
};

#endif // TRANSPORT_H
